<?php


namespace EleMe\OpenApi\Test;


use AlibabaCloud\Tea\Model;
use EleMe\OpenApi\Kernel\Factory;
use EleMe\OpenApi\Order\Models\AddTipDTO;
use EleMe\OpenApi\Order\Models\CancelOrderDTO;
use EleMe\OpenApi\Order\Models\ChainstoreRangeDTO;
use EleMe\OpenApi\Order\Models\ClaimOrderDTO;
use EleMe\OpenApi\Order\Models\ComplaintOrderDTO;
use EleMe\OpenApi\Order\Models\GetAmountDTO;
use EleMe\OpenApi\Order\Models\GetCancelReasonListDTO;
use EleMe\OpenApi\Order\Models\GetKnightInfoDTO;
use EleMe\OpenApi\Order\Models\GetOrderDetailDTO;
use EleMe\OpenApi\Order\Models\OrderDTO;
use EleMe\OpenApi\Order\Models\OrderItemOpenapiDto;
use EleMe\OpenApi\Order\Models\PreCancelOrderDTO;

class BaseAuthClientTest extends \PHPUnit\Framework\TestCase
{
    public function testAddTip(){
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
        $addTip = new AddTipDTO();
        $addTip ->partnerOrderCode = '111';
        $addTip ->thirdIndexId = 1;
        $addTip -> addTipAmountCent = '1000';
        $result = Factory::order()-> order() ->addTip($addTip);
    }

    public function testCancelOrder(){
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
        $cancelOrderDTO = new CancelOrderDTO();
        $cancelOrderDTO ->partnerOrderCode = '111';
        $cancelOrderDTO ->orderCancelRole = 2;
        $cancelOrderDTO ->orderCancelCode = 32;
        $result = Factory::order()-> order() -> cancelOrder($cancelOrderDTO);
    }

    public function testPreCancelOrder(){
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
        $cancelOrderDTO = new PreCancelOrderDTO();
        $cancelOrderDTO ->partnerOrderCode = '111';
        $cancelOrderDTO ->orderCancelRole = 2;
        $cancelOrderDTO ->orderCancelCode = 32;
        $result = Factory::order()-> order() -> preCancelOrder($cancelOrderDTO);
    }

    public function testClaimOrder(){
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
        $claimOrderDTO = new ClaimOrderDTO();
        $claimOrderDTO ->partnerOrderCode = '111';
        $claimOrderDTO ->orderClaimCode = 32;
        $claimOrderDTO ->orderClaimPriceCent = 1000;
        $result = Factory::order()-> order() ->claimOrder($claimOrderDTO);
    }

    public function testComplaintOrder(){
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
        $complaintOrderDTO = new ComplaintOrderDTO();
        $complaintOrderDTO ->partnerOrderCode = '111';
        $complaintOrderDTO ->orderComplaintCode = 32;
        $result = Factory::order()-> order() ->complaintOrder($complaintOrderDTO);
    }

    public function testCreateOrder(){
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
        $orderDTO = new OrderDTO();
        $orderDTO ->partnerOrderCode = '111';
        $orderDTO ->orderComplaintCode = 32;
        $orderDTO ->orderType = 1;
        $orderDTO ->positionSource = 3;
        $orderDTO ->receiverAddress = 'hhh';
        $orderDTO ->receiverLongitude = 11.33;
        $orderDTO ->receiverLatitude = 11.33;
        $orderDTO ->goodsTotalAmountCent = 1000;
        $orderDTO ->goodsActualAmountCent = 1000;
        $orderDTO ->goodsWeight = 20;
        $orderDTO ->goodsCount = 1;
        $itemDTO = new OrderItemOpenapiDto();
        $itemDTO ->itemId = 1;
        $itemDTO ->itemName = '花朵';
        $itemDTO ->itemActualAmountCent = 1000;
        $itemDTO ->itemAmountCent = 1000;
        $itemDTO ->itemQuantity = 8;
        $itemDTO ->itemSize = 8;
        $orderDTO->goodsItemList[0] = $itemDTO;
        $orderDTO->receiverName = 'zhangsan';
        $orderDTO->receiverPrimaryPhone = '17711111111';
        $result = Factory::order()-> order() ->createOrder($orderDTO);
    }

    public function testPreCreateOrder(){
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
        $orderDTO = new PreCancelOrderDTO();
        $orderDTO ->partnerOrderCode = '111';
        $orderDTO ->orderComplaintCode = 32;
        $orderDTO ->orderType = 1;
        $orderDTO ->positionSource = 3;
        $orderDTO ->receiverAddress = 'hhh';
        $orderDTO ->receiverLongitude = 11.33;
        $orderDTO ->receiverLatitude = 11.33;
        $orderDTO ->goodsTotalAmountCent = 1000;
        $orderDTO ->goodsActualAmountCent = 1000;
        $orderDTO ->goodsWeight = 20;
        $orderDTO ->goodsCount = 1;
        $itemDTO = new OrderItemOpenapiDto();
        $itemDTO ->itemId = 1;
        $itemDTO ->itemName = '花朵';
        $itemDTO ->itemActualAmountCent = 1000;
        $itemDTO ->itemAmountCent = 1000;
        $itemDTO ->itemQuantity = 8;
        $itemDTO ->itemSize = 8;
        $orderDTO->goodsItemList[0] = $itemDTO;
        $orderDTO->receiverName = 'zhangsan';
        $orderDTO->receiverPrimaryPhone = '17711111111';
        $result = Factory::order()-> order() ->preCreateOrder($orderDTO);
    }

    public function testGetAmount(){
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
        $getAmountDTO = new GetAmountDTO();
        $result = Factory::order()-> order() ->getAmount($getAmountDTO);
        self::assertTrue($result->balanceAmountCent == 0);
    }


    public function testGetCancelReasonList(){
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
        $getCancelReasonListDTO = new GetCancelReasonListDTO();
        $getCancelReasonListDTO -> partnerOrderCode = '1234';
        $result = Factory::order()-> order() ->getCancelReasonList($getCancelReasonListDTO);
        self::assertTrue(!empty($result->cancelReasonList) == true);
    }

    public function testChainstoreRange(){
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
        $chainstoreRangeDTO = new ChainstoreRangeDTO();
        $chainstoreRangeDTO -> chainStoreId = '22234';
        $result = Factory::order()-> order() ->getChainstoreRange($chainstoreRangeDTO);
    }

    public function testOrderDetail(){
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
        $getOrderDetailDTO = new GetOrderDetailDTO();
        $getOrderDetailDTO -> partnerOrderCode = '22234';
        $result = Factory::order()-> order() ->getOrderDetail($getOrderDetailDTO);
    }


    public function testKnightInfo(){
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
        $getKnightInfoDTO = new GetKnightInfoDTO();
        $getKnightInfoDTO ->partnerOrderCode = '22234';
        $result = Factory::order()-> order() ->getKnightInfo($getKnightInfoDTO);
    }


}